<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="file" id="f"><button onclick="sub()">提交</button>
	</body>
</html>
<script type="text/javascript">
	function sub() {
		var fd = new FormData();
		fd.append("file", document.getElementById("f").files[0])

		var xhr = new XMLHttpRequest(); //实例化原生ajax
		xhr.responseType = 'blob';
		xhr.open("post", "http://10.137.49.84:9092/yqfkContactPersonnelInfo/importData");
		xhr.setRequestHeader("Authorization","Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjU0NGJmMWFjLTdjMzktNGQwZC05YWJiLTRhNGI1NTlmOWE1NyJ9.vakDm8LTE_w6XVomLH0jwY7m8OPctQZ4A2fzgyitPUSIx_uRm4WCbwVtiHxTWgDi99W_8tnCQE7Lb02kd9loPw")
		
		xhr.onload = function() {
			console.log(this)
			if (this.status == 200) {
				const blob = new Blob([this.response], {
					type: "blob"
				})
				const downloadElement = document.createElement('a')
				let href = window.URL.createObjectURL(blob)
				downloadElement.href = href

				downloadElement.download = "导入反馈数据.xlsx";
				document.body.appendChild(downloadElement)
				downloadElement.click()
				document.body.removeChild(downloadElement) // 下载完成移除元素
				window.URL.revokeObjectURL(href) // 释放掉blob对象
			}
		};
		xhr.send(fd);
	}
</script>
